package com.atguigu.yygh.task.scheduled;

import com.atguigu.yygh.common.service.MqConst;
import com.atguigu.yygh.common.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author DongYu Zhou
 * @date 2022/7/10 7:47
 */
@Component
@EnableScheduling
public class ScheduledTask {
    @Autowired
    private RabbitService rabbitService;
//    @Scheduled(cron = "0/5 * * * * ?")
//    public void test(){
//        System.err.println("定时任务执行！！！！！！！！");
//    }

    @Scheduled(cron = "0 0 8 * * ?")
    public void task1(){
        System.out.println(new Date().toLocaleString());
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,
                MqConst.ROUTING_TASK_8,"");
    }

}

